package main

import (
	"compress/gzip"
	"fmt"
	"io"
	"os"
)

func main() {

	f, err := os.Open("1.txt")
	if err != nil {
		fmt.Println("open file failed:", err)
		return
	}

	defer f.Close()
	zw, _ := gzip.NewReader(f)
	defer zw.Close()

	i := 1
	for {
		buf := make([]byte, 32)
		_, err = zw.Read(buf)
		if err != nil {
			if err == io.EOF {
				fmt.Printf("第%d次读取压缩数据为: %q\n", i, buf)
				fmt.Println("meet file EOD")
				return
			} else {
				fmt.Printf("第%d次读取压缩数据失败: %v\n", i, err)
			}

		}
		fmt.Printf("第%d次读取压缩数据为: %q\n", i, buf)

	}

}
